import request from '@/utils/request'

/**
 * 分页查询货币种类信息
 * @param {*} query
 */
export function fetchList(query) {
  return request({
    url: '/base/dictCurrency/list',
    method: 'get',
    params: query
  })
}

/**
 * 创建货币种类信息
 * @param {*} dictCur
 */
export function createDictCurrency(dictCur) {
  return request({
    url: '/base/dictCurrency/create',
    method: 'post',
    data: dictCur
  })
}

/**
 * 更新货币种类信息
 * @param {*} dictCur
 */
export function updateDictCurrency(dictCur) {
  return request({
    url: '/base/dictCurrency/update',
    method: 'post',
    data: dictCur
  })
}

/**
 * 删除货币种类信息
 * @param {*} curCode
 */
export function deleteDictCurrency(curCode) {
  return request({
    url: '/base/dictCurrency/delete',
    method: 'post',
    params: { curCode }
  })
}

/**
 * 上传文件批量导入货币种类信息
 * @param {*} fileobj
 * @param {*} obj
 */
export function importDictCurrencys(fileobj, obj) {
  if (!fileobj || !fileobj.file) {
    return {}
  }
  const param = new FormData()
  if (obj) {
    for (const key of obj) {
      param.append(key, obj[key])
    }
  }
  param.append('file', fileobj.file)
  return request({
    method: 'post',
    url: '/base/dictCurrency/import',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}

/**
 * 导出货币种类信息Excel文件
 * @param {*} query
 */
export function exportDictCurrencys(query) {
  return request({
    url: '/base/dictCurrency/export',
    method: 'get',
    params: query
  })
}

/**
 * 导出货币种类信息Excel模板
 */
export function exportDictCurrencyTemplate() {
  return request({
    url: '/base/dictCurrency/exportTemplate',
    method: 'get'
  })
}
